import Page
from Page import Motorcade
from Base.Base import Base
from selenium.webdriver.common.by import By


class MotorcadeDetailsPage(Base):
    """
    车队详情页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.details_home_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.details_back_btn = (By.XPATH, Motorcade.RESOURCE_ID.format('ivBack'))

        # 加入车队标题
        self.details_add_car_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("tv_join_motorcade_num_text"))

        # 加入车队数量
        self.details_add_car_number_text = (By.XPATH, Motorcade.RESOURCE_ID.format("tv_join_motorcade_num"))

        # 加入车队图标
        self.details_add_list_car_icon = (By.XPATH, Motorcade.add_car_icon.format(""))

        # 加入车队文字
        self.details_add_list_car_explanation_text = (By.XPATH, Motorcade.add_car_text.format(""))

        # 创建车队图标
        self.details_list_create_car_icon = (By.XPATH, Motorcade.create_car_icon.format(""))

        # 创建车队文字
        self.details_list_create_car_explanation_text = (By.XPATH, Motorcade.create_car_text.format(""))

        # 车队列表图标
        self.details_list_car_img_icon = (By.XPATH, Motorcade.motorcade_car_avatar_icon.format(""))

        # 车队列表车队名称
        self.details_list_car_name_text = (By.XPATH, Motorcade.motorcade_car_name_text.format(""))

        # 车队口令
        self.details_list_car_password_text = (By.XPATH, Motorcade.motorcade_car_password_text.format(""))

        # 信息设置按钮
        self.details_car_information_setting_btn = (
            By.XPATH, Motorcade.motorcade_car_information_settings_btn.format(""))

        # 退出车队按钮
        self.details_car_quit_btn = (By.XPATH, Motorcade.motorcade_car_quit_btn.format(""))

        # 人数角标
        self.details_car_number_people_text = (By.XPATH, Motorcade.motorcade_car_number_people_text.format(""))

        # 退出车队标题
        self.details_car_quit_tip_text = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm_dialog_title"))

        # 退出车队说明
        self.details_car_quit_explanation_text = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm_dialog_content"))

        # 确认按钮
        self.details_quit_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("btn_confirm_sure"))

        # 取消按钮
        self.details_quit_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("btn_confirm_cancel"))

        # 加入车队标题
        self.details_car_add_tip_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title"))

        # 加入车队输入框
        self.details_car_add_explanation_input = (By.XPATH, Motorcade.RESOURCE_ID.format("blt_name_et"))

        # 确认按钮
        self.details_add_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm"))

        # 取消按钮
        self.details_add_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.details_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.details_back_btn)

    def get_add_car_title(self):
        """
        获得详情页车队标题

        :return:获取元素
        """
        return self.find_element_o(self.details_add_car_title_text)

    def get_add_car_number(self):
        """
        获得详情页加入车队数量

        :return:获取元素
        """
        return self.find_element_o(self.details_add_car_number_text)

    def get_add_list_car(self, index=1):
        """
        获得详情页加入车队图标

        index 默认为1
        :return:获取元素
        """
        self.details_add_list_car_icon = (By.XPATH, Motorcade.add_car_icon.format(index))
        return self.find_element_o(self.details_add_list_car_icon)

    def click_add_list_car_explanation(self, index=1):
        """
        点击详情页加入车队文字

        index 默认为1
        :return:None
        """
        self.details_add_list_car_explanation_text = (By.XPATH, Motorcade.add_car_text.format(index))
        self.click_element(self.details_add_list_car_explanation_text)

    def get_list_create_car(self, index=2):
        """
        获得详情页创建车队图标

        index 默认为2
        :return:获取元素
        """
        self.details_list_create_car_icon = (By.XPATH, Motorcade.create_car_icon.format(index))
        return self.find_element_o(self.details_list_create_car_icon)

    def click_list_create_car_explanation(self, index=2):
        """
        点击详情页创建车队文字

        index 默认为2
        :return:None
        """
        self.details_list_create_car_explanation_text = (By.XPATH, Motorcade.create_car_text.format(index))
        self.click_element(self.details_list_create_car_explanation_text)

    def get_list_car_img(self, index=1):
        """
        获得详情页车队图标

        index 默认为1
        :return:获取元素
        """
        self.details_list_car_img_icon = (By.XPATH, Motorcade.motorcade_car_avatar_icon.format(index))
        return self.find_element_o(self.details_list_car_img_icon)

    def get_list_car_name(self, index=1):
        """
        获得详情页车队名称

        index 默认为1
        :return:获取元素
        """
        self.details_list_car_name_text = (By.XPATH, Motorcade.motorcade_car_name_text.format(index))
        return self.find_element_o(self.details_list_car_name_text)

    def get_list_car_password(self, index=1):
        """
        获得详情页车队口令

        index 默认为1
        :return:获取元素
        """
        self.details_list_car_password_text = (By.XPATH, Motorcade.motorcade_car_password_text.format(index))
        return self.find_element_o(self.details_list_car_password_text)

    def click_list_car_password(self, index=1):
        """
        点击详情页车队口令

        index 默认为1
        :return:None
        """
        self.details_list_car_password_text = (By.XPATH, Motorcade.motorcade_car_password_text.format(index))
        self.click_element(self.details_list_car_password_text)

    def click_car_information_setting(self, index=1):
        """
        点击详情页车队信息设置按钮

        index 默认为1
        :return:None
        """
        self.details_car_information_setting_btn = (
            By.XPATH, Motorcade.motorcade_car_information_settings_btn.format(index))
        self.click_element(self.details_car_information_setting_btn)

    def click_car_quit(self, index=1):
        """
        点击详情页车队信息退出车队按钮

        index 默认为1
        :return:None
        """
        self.details_car_quit_btn = (By.XPATH, Motorcade.motorcade_car_quit_btn.format(index))
        self.click_element(self.details_car_quit_btn)

    def get_car_number_people(self, index):
        """
        获得详情页车队人数角标

        index 默认为1
        :return:获取元素
        """
        self.details_car_number_people_text = (By.XPATH, Motorcade.motorcade_car_number_people_text.format(index))
        return self.find_element_o(self.details_car_number_people_text)

    def is_display_motorcade_details(self):
        """
        是否进入车队详情页

        :return: bool
        """
        return self.is_display(self.details_add_car_title_text)

    def swipe_motorcade_details(self):
        """
        滑动详情页

        :return: None
        """
        return self.swipe_o(location=(940, 1510, 256, 256), direction='lift')

    def get_car_quit_tip(self):
        """
        获得退出车队标题

        :return:获取元素
        """
        return self.find_element_o(self.details_car_quit_tip_text)

    def get_car_quit_explanation(self):
        """
        获得退出车队说明

        :return:获取元素
        """
        return self.find_element_o(self.details_car_quit_explanation_text)

    def click_quit_ok(self):
        """
        点击退出确认按钮

        :return:None
        """
        self.click_element(self.details_quit_ok_btn)

    def click_quit_no(self):
        """
        点击退出取消按钮

        :return:None
        """
        self.click_element(self.details_quit_no_btn)

    def is_display_motorcade_quit(self):
        """
        是否进入退出车队页面

        :return: bool
        """
        return self.is_display(self.details_car_quit_tip_text)

    def get_car_add_tip(self):
        """
        获得加入车队标题

        :return:获取元素
        """
        return self.find_element_o(self.details_car_add_tip_text)

    def input_car_add_explanation(self, index):
        """
        点击加入车队输入框

        index为输入的车队口令
        :return:None
        """
        self.input_text(self.details_car_add_explanation_input, index)

    def click_add_ok(self):
        """
        点击加入确认按钮

        :return:None
        """
        self.click_element(self.details_add_ok_btn)

    def click_add_no(self):
        """
        点击退出取消按钮

        :return:None
        """
        self.click_element(self.details_add_no_btn)

    def is_display_motorcade_add(self):
        """
        是否进入加入车队页面

        :return: bool
        """
        return self.is_display(self.details_car_add_tip_text)


if __name__ == '__main__':
    pass
